package com.medicine.manage.block.service.impl;

import com.medicine.manage.block.EncryptUtils;
import com.medicine.manage.block.entity.WeBaseResult;
import com.medicine.manage.block.service.AbstractBlockService;
import com.medicine.manage.block.service.IBlockProcessService;
import com.medicine.manage.block.service.IBlockService;
import com.medicine.manage.domain.OrderConfirm;
import org.springframework.stereotype.Service;

@Service("blockProcessConfirmService")
public class BlockProcessConfirmServiceImpl extends AbstractBlockService<OrderConfirm> implements IBlockProcessService<OrderConfirm> {


    private final String INSERT_ONE_METHOD = "insertOrderConfirm";
    private final String SELECT_ONE_METHOD = "selectOrderConfirm";
    private final String UPDATE_METHOD = "updateOrderConfirm";

    @Override
    public WeBaseResult insertProcessObj(OrderConfirm orderConfirm, Long deptId, Long optionUserId) {
        return this.insertOne(orderConfirm, deptId, optionUserId, INSERT_ONE_METHOD);
    }

    @Override
    public WeBaseResult selectProcessObj(Long orderId, Long confirmId, Long deptId, Long optionUserId) {
        return this.selectOne(orderId, confirmId, deptId, optionUserId, SELECT_ONE_METHOD);
    }

    @Override
    public WeBaseResult updateProcessObj(OrderConfirm orderConfirm, Long deptId, Long optionUserId) {
        return this.update(orderConfirm.getOrderId(),  orderConfirm, deptId, optionUserId, UPDATE_METHOD);
    }


    @Override
    protected String createParam(OrderConfirm o, Long optionUserId) {
        StringBuffer param = new StringBuffer();
        param.append(o.getOrderId()).append(IBlockService.SEPARATOR)
                .append(o.getId()).append(IBlockService.SEPARATOR)
                .append(o.getImage()!=null ? EncryptUtils.sha256(o.getImage()):"").append(IBlockService.SEPARATOR)
                .append(optionUserId);

        return param.toString();
    }
}
